# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=weechat-matrix
pkgver=0.3.0_git20220126
pkgrel=0
_commit="0f4d83078accdc51f31b2041af7d41ebf17ce93d"
pkgdesc="WeeChat Matrix protocol script"
url="https://github.com/poljar/weechat-matrix"
arch="noarch"
license="MIT"
depends="
	py3-aiohttp
	py3-attrs
	py3-magic
	py3-matrix-nio
	py3-openssl
	py3-pygments
	py3-requests
	py3-webcolors
	python3
	weechat
	weechat-python
	xdg-utils
	"
makedepends="
	poetry
	py3-build
	py3-importlib-metadata
	py3-installer
	py3-poetry-core
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-hypothesis
	py3-pytest
	"
install="$pkgname.post-install"
source="$pkgname-$_commit.tar.gz::https://github.com/poljar/weechat-matrix/archive/$_commit.tar.gz"
builddir="$srcdir/$pkgname-$_commit"

build() {
	# XXX: hack for poetry to not ignore files
	GIT_DIR=. python3 -m build --skip-dependency-check --no-isolation --wheel .
}

check() {
	python3 -m pytest
}

package() {
	python3 -m installer --destdir="$pkgdir" dist/*.whl
	install -Dm755 main.py "$pkgdir/usr/share/weechat/python/weechat-matrix.py"

	for _script in matrix_decrypt matrix_sso_helper matrix_upload
	do
		install -Dm755 "contrib/$_script.py" "$pkgdir/usr/bin/$_script"
	done
}

sha512sums="
26105a1ed090277c3bf30fd2d18ced0379320efc1be72ee75b4d4385b3c041a174d0b2e514ea4a1c6c4fa8267ac6ba21e2ddc69d72b4558cb5fb5d533aae1e14  weechat-matrix-0f4d83078accdc51f31b2041af7d41ebf17ce93d.tar.gz
"
